package cn.btks.resultintegration.rule.controller;

import cn.btks.commonserver.result.ResultState;
import cn.btks.commonserver.result.StateInfo;
import cn.btks.resultintegration.rule.pojo.EIASecondCategory;
import cn.btks.resultintegration.rule.pojo.EncourageCategory;
import cn.btks.resultintegration.rule.service.EncourageCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author lijun
 * @Date 2021/3/28 12:31
 */
@RestController
@RequestMapping("api/v1.0/resultIntegration/rule")
@Api(tags = "规则模块")
@Validated
public class EncourageCategoryController {

    @Autowired
    EncourageCategoryService encourageCategoryService;

    @GetMapping("/encourageCategory/findAllByCategoryId/{categoryId}")
    @ApiOperation("根据产业调整大类ID查询鼓励类")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "categoryId", value = "分类管理名录一级ID", required = true, dataType = "long"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAllByEiaCategoryId(@PathVariable("categoryId") Long categoryId) {
        List<EncourageCategory> encourageCategoryList = encourageCategoryService.findAllByCategoryId(categoryId);
        return encourageCategoryList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), encourageCategoryList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }
}
